package com.example.kt_base.s6

//TODO 109.Kotlin语言的[ ]操作符学习
class KtBase109<T>(val isR:Boolean,vararg objects:T){

    val objectArray:Array<out T> =objects
    fun getR1()=objectArray.takeIf { isR }
    fun getR2()=objectArray.takeIf { isR }

    fun getR3(index:Int)=objectArray[index].takeIf { isR }

    operator fun get(index: Int)=objectArray[index].takeIf { isR }
}
fun main() {
  val p=  KtBase109(true,"jenny",123,66.6)

    println(p[0])

}
